import Vue from 'vue'

import VueRouter from 'vue-router'
let originPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location, resolve, reject) {
    if (resolve && reject) {
        originPush.call(this, location, resolve, reject)
    } else {
        originPush.call(this, location, () => { console.log(123); }, () => { })
    }
}

let originReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function (location, resolve, reject) {
    if (resolve && reject) {
        originReplace.call(this, location, resolve, reject)
    } else {
        originReplace.call(this, location, () => { }, () => { })
    }
}
Vue.use(VueRouter)

const router = {
    routes: [
        {
            path: '/one',
            name: 'one',
            component: () => import('../views/One.vue')
        },
        {
            path: '/two',
            name: 'two',
            component: () => import('../views/Two.vue')
        }, {
            path: '/three',
            name: 'three',
            component: () => import('../views/Three.vue')
        }, {
            path: '/four',
            name: 'four',
            component: () => import('../views/Four.vue')
        }, {
            path: '/five',
            name: 'five',
            component: () => import('../views/Five.vue')
        },
        {
            path: '*',
            redirect: '/one'
        },

    ],
    scrollBehavior: (to) => {
        return { y: 0 }
    }

}

export default new VueRouter(router)